<template>
  <el-row>
    <div class="detailCont detailDialogFont twoDetailStyle">
      <h1>基础信息</h1>
      <ul>
        <li>
          <b>保养单号</b>
          <span>{{ objInfo.maintainNo }}</span>
        </li>
        <li>
          <b>设备</b>
          <span>{{ objInfo.equipName}}{{ objInfo.equipCode ? '【' + objInfo.equipCode + '】' : '' }}</span>
        </li>
        <li>
          <b>保养分类</b>
          <span>{{ objInfo.classifyName }}</span>
        </li>
        <li>
          <b>设备类型</b>
          <span>{{ objInfo.equipType }}</span>
        </li>
        <li>
          <b>状态</b>
          <span>{{ objInfo.status == 1 ? '新建' : objInfo.status == 2 ? '保养中':'已完成' }}</span>
        </li>
        <li>
          <b>下达人</b>
          <span>{{ objInfo.releaseName }}</span>
        </li>
        <li>
          <b>下达时间</b>
          <span>{{ objInfo.releaseTime }}</span>
        </li>
        <div v-if="objInfo.status === 3">
          <li>
            <b>保养人</b>
            <span>{{ objInfo.maintainByName }}</span>
          </li>
          <li>
            <b>开始时间</b>
            <span>{{ objInfo.startTime}}</span>
          </li>
          <li>
            <b>结束时间</b>
            <span>{{ objInfo.endTime }}</span>
          </li>
          <li>
            <b>保养工时</b>
            <span>{{ objInfo.maintainHours }}小时</span>
          </li>
        </div>
      </ul>
      <p style="text-align:right;">
        <el-button type="primary" icon="el-icon-check" @click="startBtn">开始</el-button>
      </p>
    </div>
  </el-row>
</template>

<script>
export default {
  props: {
    objInfo: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  data() {
    return {}
  },

  watch: {},

  mounted() {},

  methods: {
    /* 开始 */
    startBtn() {
      this.$confirm(`确认开始任务？`, '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(async () => {
          const res = await this.$axios.post(
            `/equip/maintain/task/start/${this.objInfo.id}`
          )
          if (res.data.code === 200) {
            this.$notify.success('开始成功！')
            this.$emit('closeBtn')
          } else {
            this.$notify.error(res.data.msg)
          }
        })
        .catch(() => {})
    }
  }
}
</script>

<style lang='scss' scoped>
</style>

<style lang="scss">
</style>
